<?php
    
    class MArticle {
        
        private $data;
        private $render = false;
        private $source = false;
        
        public function __construct($template){
            
            $file = WEB_PATH . '/views/' . $template . '.php';
            
            if(file_exists($file)){
                $this->render = $file;
            }
            
        }
        
        public function setData($data, $type=false){ $this->data = $data; $this->source = $type; } 
        
        public function output($direct = true){
            if($direct !== true){
                ob_start();
            }
            
            $data = $this->data;
            
            if($this->source != false){
                $data_id = $this->source;
                include($this->render);
            }else{
                include($this->render);
            }
            
            if($direct !== true){
                ob_clean();
            }
        }
        
    }
    
?>